﻿using System.Collections.Generic;
using System.Linq;

namespace System.Collections.ObjectModel
{
	public static class ObservableCollectionExtensions
	{
		public static void AddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> items)
		{
			if (items == null) return;
			foreach (var item in items)
				collection.Add(item);
		}

		public static void RemoveAll<T>(this ObservableCollection<T> collection, Func<T, bool> predicate)
		{
			if (predicate == null) throw new ArgumentNullException("predicate");
			var itemsToRemove = collection.Where(predicate).ToList();
			foreach (var item in itemsToRemove) collection.Remove(item);
		}
	}
}
